// Have include guard.
#ifndef STATEDONECODE_H
#define STATEDONECODE_H

/**
 * The StateDoneCode class is used as an exit code for States.
 * 
 * The State class finishs by setting a StateDoneCode other than "NotDone".
 * 
 * Code -1 is reserved to indicate that the State is not done yet.
 * Codes [0, Inf) indicates an end result expected in a perfectly working program.
 * Code 0 is reserved to indicate general success.
 * Code 1 is reserved to indicate simply "not yet".  Useful for something like a "CheckSensorState".
 * Codes (-Inf, -2] indicates an error.
 * Code -2 indicates a generic error.
 * Code -3 indicates that the operation was canceled in an unintended manner.
 * The entire range [-0x0A, 0x0A] is reserved to be definied by FPK.
 * The rest of the codes may be defined anyway you like. 
 */
class StateDoneCode
{
	public:
		static StateDoneCode GetNotYetCode();
		static StateDoneCode GetSuccessCode();
		static StateDoneCode GetNotDoneCode();
		static StateDoneCode GetGenericErrorCode();
		static StateDoneCode GetCancelErrorCode();
		
		StateDoneCode(int code);
		StateDoneCode(const StateDoneCode &code);
		int GetCode() const;
		bool IsDone() const;
		bool IsError() const;
		
		bool operator ==(StateDoneCode other) const;
		bool operator !=(StateDoneCode other) const;
		bool operator <(StateDoneCode other) const;
		bool operator >(StateDoneCode other) const;
		bool operator <=(StateDoneCode other) const;
		bool operator >=(StateDoneCode other) const;
	protected:
		int m_code;
};

#endif // #ifndef STATEDONECODE_H 
